`include "common.svh"

import "DPI-C" function int perf_event_reset(
  int id,
  input string name
);
import "DPI-C" function void perf_event_accumulate(
  input int id,
  input int inc
);

module perf_event #(
    parameter PERF_NAME = "",
    parameter WIDTH = 1
) (
    input clk,
    input [WIDTH-1:0] inc
);

  int id = 0;
  initial begin
    id = perf_event_reset(id, PERF_NAME);
  end
  always_ff @(posedge clk) begin
    if (inc != 'b0) perf_event_accumulate(id, {{(32 - WIDTH) {1'b0}}, inc});
  end
endmodule
